//
// Created by 朱语 on 2022/8/4.
//
#include <iostream>
#include "graph.h"
using namespace std;

int main(){

    const int max = 1000000000;

    //生成六节点图
    graph g(6);
    graph g_weighted(6, max);
    //设定边，无权图
    vector<vector<int>> init = {
            {1, 2},
            {0, 3},
            {1, 0},
            {2, 4},
            {3, 5},
            {3, 4},
            {4, 1}
    };
    //有权图
    vector<vector<int>> init_weighted = {
            {1, 2, 3},
            {0, 3, 1},
            {1, 0, 5},
            {2, 4, 8},
            {3, 5, 0},
            {3, 4, 4},
            {4, 1, 6}
    };

    g.build(init);
    g_weighted.build((init_weighted));

    //检查图是否联通
    if(g.connected())
        cout<<"detect: connected graph"<<endl;
    else{
        cout<<"detect: unconnected graph"<<endl;
        exit(0);
    }

    if(g_weighted.connected())
        cout<<"detect: connected graph"<<endl;
    else{
        cout<<"detect: unconnected graph"<<endl;
        exit(0);
    }

    //遍历图
    g.DFS(2);
    g.BFS(2);
    //无权图最短路径
    g.UnWeighted(0);
    //有权图最短路径
    g_weighted.Dijkstra(0);
    g_weighted.Floyd();
    //最小生成树
    g_weighted.Prim(1);
    g_weighted.Kruskal();

}
